package org.gongzhen.HomeMapper;

import org.apache.ibatis.annotations.*;
import org.gongzhen.Like;
import org.gongzhen.Save;

@Mapper
public interface PostLikeMapper {

    /**
     * 绑定点赞者和帖子的关系
     * @param
     * @param
     */
    @Insert("insert into `like`(user_id, post_id, create_time) values (#{userId}, #{postId}, #{createTime})")
    void like(Like like);

    /**
     * 查询用户是否已经点在该帖子
     * @param postId
     * @param userId
     */
    @Select("select * from `like` where post_id = #{postId} and user_id = #{userId}")
    Like getByUserIdAndPostId(Integer postId, Integer userId);

    /**
     * 删除点赞信息
     * @param id
     */
    @Delete("delete from `like` where id = #{id}")
    void deleteById(Integer id);

}
